package org.catdroid.bootcamp.android;

import org.catdroid.bootcamp.android.bean.Task;
import org.catdroid.bootcamp.android.bean.Tasks;

import android.app.Activity;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;

import com.googlecode.androidannotations.annotations.AfterViews;
import com.googlecode.androidannotations.annotations.Background;
import com.googlecode.androidannotations.annotations.Click;
import com.googlecode.androidannotations.annotations.EActivity;
import com.googlecode.androidannotations.annotations.NoTitle;
import com.googlecode.androidannotations.annotations.UiThread;
import com.googlecode.androidannotations.annotations.ViewById;
import com.googlecode.androidannotations.annotations.rest.RestService;

@NoTitle
@EActivity(R.layout.main)
public class MainActivity extends Activity {

	
	@ViewById
	ProgressBar progress;
	
	@RestService
	TaskRest taskRest;

	private Tasks tasks;
	
	@AfterViews
	public void init() {
		progress.setVisibility(View.VISIBLE);
		loadData();
	}
	
	@Background
	public void loadData() {
		tasks = taskRest.getTasks();
		showData();
	}
	
	
	@UiThread
	public void showData() {
		progress.setVisibility(View.GONE);
		for (Task task:tasks) {
			Toast.makeText(this, task.getId()+"\r\n"+task.getTitle()+"\r\n"+task.getMessage(), Toast.LENGTH_LONG).show();
		}
	}
	
	
	
	
	
	
	@Click
	public void salutationClicked() {
		Toast.makeText(this, "wow", Toast.LENGTH_LONG).show();
	}
}